package com.rabbitmq.exec.ttl;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.exec.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;

/**
 * @Description
 * @Author lhj
 * @Date 2024/4/18 21:19
 */
public class Producer {
    public static final String EXCHANGE_NAME = "normal_exchange";
    public static void main(String[] args) throws Exception {
        try (Channel channel = RabbitMqUtils.getChannel()){
            //声明一个交换机
            channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);
//            AMQP.BasicProperties properties = new AMQP.BasicProperties().builder().expiration("10000").build();
            for (int i = 1; i < 11; i++) {
                String message = "info" + i;
                channel.basicPublish(EXCHANGE_NAME, "zhangsan", null, message.getBytes(StandardCharsets.UTF_8));
                System.out.println("生产者发送消息: " + message);
            }
        }
    }
    
}
